import * as Cesium from '@cesiumjs';
import * as mobx from 'mobx';
import g3xExtends from "./extends";
import {
  G3vObj
} from "@g3xbase"

/* 194 */
/***/

class CirclesRotating extends G3vObj {

  constructor(g3vViewer, options) {

    super(g3vViewer.viewer, options);
    
    this._g3vViewer = g3vViewer

    var _this = this;

    mobx.extendObservable(_this, {
      position: [0, 0, 0],
      rotation: [0, 0, 0],
      scale: 1.0,
      fixScreenSize: 100,
      toleranceSize: 6,
      headingCircleActive: false,
      pitchCircleActive: false,
      rollCircleActive: false,
      headingEnabled: true,
      pitchEnabled: true,
      rollEnabled: true
    });

    mobx.extendObservable(_this, {
      _oldRotation: [0, 0, 0],
      _startRotation: [0, 0, 0],
      _endRotation: [0, 0, 0]
    });

    mobx.extendObservable(_this, {
      isCameraLike: false
    });

    _this._centerCartesian = new Cesium.Cartesian3();
    _this._enu = new Cesium.Matrix4();
    _this._enuChangedEvent = new Cesium.Event();

    function updateEnu(position) {
      const _Cesium$Cartesian = Cesium.Cartesian3;
      const _centerCartesian = _this._centerCartesian;
      _this._centerCartesian = _Cesium$Cartesian.fromRadians.apply(_Cesium$Cartesian, [...position, undefined, _this
        ._centerCartesian
      ]);
      _this._enu = Cesium.Transforms.eastNorthUpToFixedFrame(_this._centerCartesian, undefined, _this._enu);
      _this._enuChangedEvent.raiseEvent();
    };

    updateEnu(_this.position);

    _this.disposers.push(mobx.reaction(function() {
      return {
        enabled: _this.enabled,
        position: [..._this.position],
      };
    }, function(_ref) {
      _ref.enabled && updateEnu(_ref.position);
    }));

    mobx.extendObservable(_this, {
      _realSceneScale: 1.0
    });

    _this.disposers.push((0, _updateRealSceneScale2.default)(_this._earth, _this));

    _this._createDirections();

    _this._createBaseCircles();

    _this._createCenterModel();

    return _this;
  }
}

(0, g3xExtends)(CirclesRotating);

export default CirclesRotating;
